/**
 * Copyright 2009 University of  Washington
 * This code is released under the GPL version 3 - with a copy of the license included
 * @author Maya Hao Li
 *
 */
package seedpod.model.custom;

import java.sql.Timestamp;

import seedpod.model.NoObjectFoundException;
import seedpod.model.SeedpodDO;
import seedpod.model.SeedpodModel;
import seedpod.rdb.PManager;
import seedpod.util.Util;


public class AccessLog extends SeedpodDO {

	public static final String CLASSTYPE = SeedpodModel.RdbCls.ACCESS_LOG;
	private SeedpodUser _user;

	private String _event;

	private Timestamp _logTimestamp;

	public AccessLog(Integer oid, PManager manager ) throws NoObjectFoundException {
		super(oid, manager);
	}
	
	public AccessLog(SeedpodUser user, String event, PManager manager) throws NoObjectFoundException {
		super( SeedpodModel.RdbCls.ACCESS_LOG, manager );
		_user = user;
		_event = event;
		_logTimestamp = Util.getCurrentTimestamp();
	}

	// in the case that no logged in user was identified.
	public AccessLog(String event, PManager manager) throws NoObjectFoundException {
		super( SeedpodModel.RdbCls.ACCESS_LOG, manager );
		_event = event;
	}
	
	public SeedpodUser getUser(){
		return _user;
	}
	
	
	
	public String getEvent() {
		return _event;
	}
	
	public String getTimestamp() {
		return _logTimestamp.toString();
	}
	
	public String getLabel() {
		return getTimestamp() + " - " + getEvent() + " (" + getUser().getLabel() + ")";
	}
	
}
